<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        li {
            list-style: none;
        }

        a {
            text-decoration: none;
        }
        header a{
            text-decoration: none;
            color: #6c6c6c;
        }
        .el-table .el-table__cell{
            padding: 0;
        }
        .el-table .cell{
            white-space: nowrap;/*设置内容不换行*/
            text-overflow: ellipsis;/*有超出显示范围的文本时显示...*/
        }
        .use{
            padding: 15px 5px 0 5px;
            margin: 0 auto;
            display: inline-block;
            text-align: center;
        }
        .small_img{
            margin: 0 1px;
            border: 1px solid red;
        }

    </style>
</head>
<body>
<div id="app">
    <el-container>
        <el-header height="150px">
            <div style="width: 1300px;margin: 0 auto">
                <img src="imgs/logo.png" style="width: 300px;vertical-align: middle;" alt="">
                <div style="width:500px;position: relative;top: 10px;display: inline-block;margin: 0 120px">
                    <el-input style="border: #39bf3e 1px solid" placeholder="请输入搜索内容" v-model="wd">
                        <el-button style="border-left:none;background-color: #39bf3e;color: #fff;" slot="append" icon="el-icon-search" @click="search()">搜索</el-button>
                    </el-input>
                </div>
                <div style="display: inline-block;margin-top:50px;position: relative;left: 100px">
                    <div class="use">
                        <el-button  icon="el-icon-user-solid"></el-button>
                    </div>
                    <h5 style="display: inline-block">欢迎{{uname}}回来</h5>
                </div>
            </div>
            <!--导航菜单开始-->
            <div>
                <el-menu style="width: 1300px;margin: 0 auto;"
                         :default-active="activeIndex"
                         class="el-menu-demo"
                         mode="horizontal"
                         @select="handleSelect"
                         background-color="#39bf3e"
                         text-color="#fff"
                         active-text-color="#fff">
                    <el-menu-item style="font-size: 16px;padding:0 25px" :index="0">首页</el-menu-item>
                    <el-menu-item style="font-size: 16px;" v-for="c in categoryArr"  :index="c.id">{{c.name}}</el-menu-item>
                </el-menu>
            </div>
        </el-header>
        <el-main style="width: 1200px;margin: 50px auto">
            <el-row gutter="20">
                <el-col span="10">
                    <el-card  style="background-color: #FFEFD5;">
                        <img :src="productImg.url" width="100%" alt="">
                    </el-card>
                    <el-card  style="background-color: #FFDEAD;">
                        <img class="small_img" v-for="p in productImgArr" @click="show(p)" :src="p.url"  width="19%" alt="">
                    </el-card>
                </el-col>
                <el-col span="14" >
                    <p style="font-size: 40px;font-weight: bold">
                        眉县徐香猕猴桃,精品大果,代发,现摘,现发,包邮,包售后
                    </p>
                    <p style="font-size: 5px">
                        当季水果，绿色猕猴桃，坏果包赔，产地直供
                    </p>
                    <el-divider></el-divider>
                    <div style="margin: 0 0 0 50px">
                    <p style="font-size: 25px;font-weight: bold">
                        价格:${{product.price}}
                        <span style="font-size: 25px;color: #666">原价:<s>{{product.oldPrice}}</s></span>
                    </p>
                    <p style="font-size: 25px;">浏览量:{{product.viewCount}}</p>
                    <p style="font-size: 25px;">库存:{{product.num}}</p>
                    <p style="font-size: 25px;">上架时间:{{product.created}}</p>
                    <div style="width: 500px;height: 100px;">
                        <el-button size="medium" type="success">立即购买</el-button><el-button size="medium" type="danger">联系商家</el-button>
                    </div>
                    </div>
                </el-col>
            </el-row>
        </el-main>
        <el-footer>
            <div style="background-color: #3f3f3f;padding:30px 0;text-align: center;color: #b1b1b1">
                <p>Copyright © 北京达内金桥科技有限公司版权所有 京ICP备12003709号-3 京公网安备 11010802029572号
                </p>
                <p>达内在线WWW.TMOOC.CN 专注于IT职业技能培训</p>
                <p>涵盖20余门课程体系，致力于打造权威的IT职业教育学习平台</p>
            </div>
        </el-footer>
    </el-container>
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
   let v = new Vue({
        el: '#app',
        data: function() {
            return {
                productImg:{
                    id:"",
                    productId: "",
                    url:""
                },
                product:{
                    id:"1",
                    title:"",
                    price:"",
                    oldPrice:"",
                    viewCount:"",
                    num:"",
                    created:"",
                    categoryId:""
                },
                productImgArr:[],
                bannerArr: [],
                categoryArr: [],
                activeIndex:"0",
                wd:"",
                topArr:[],
                uname:"",
                visible:true

            }
        },
       methods:{
           handleSelect(key,keyPath){
               console.log(key,keyPath);
               location.href="/result.html?id="+key;
           },
           search(){
               location.href="/result.html?wd="+v.wd;
           },
           show(productImg){
               v.productImg=productImg
           }
       },
       created:function () {
           axios.get("/select?id="+this.product.id).then(function (response) {
               v.productImgArr = response.data;
               v.productImg = v.productImgArr[0];
           })
           axios.get("/selectById?id="+this.product.id).then(function (response) {
               v.product = response.data;
           })
           axios.get("/category/select").then(function (response) {
               v.categoryArr = response.data;
           })
       }
    })
</script>
</html>